﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class Emp_AssessmentModel
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private int _EmpBasicID;
        [DataMember]
        public int EmpBasicID
        {
            get { return _EmpBasicID; }
            set { _EmpBasicID = value; }
        }

        private string _AssessmentType = string.Empty;
        [DataMember]
        public string AssessmentType
        {
            get { return _AssessmentType; }
            set { _AssessmentType = value; }
        }

        private string _AssessmentResult = string.Empty;
        [DataMember]
        public string AssessmentResult
        {
            get { return _AssessmentResult; }
            set { _AssessmentResult = value; }
        }

        private DateTime? _AssessmentDate = null;
        [DataMember]
        public DateTime? AssessmentDate
        {
            get { return _AssessmentDate; }
            set { _AssessmentDate = value; }
        }

        private string _EmpName = string.Empty;
        [DataMember]
        public string EmpName
        {
            get { return _EmpName; }
            set { _EmpName = value; }
        }

        private string _EmpNo = string.Empty;
        [DataMember]
        public string EmpNo
        {
            get { return _EmpNo; }
            set { _EmpNo = value; }
        }

        public static Emp_AssessmentModel FillEntity(DataRow dr)
        {
            Emp_AssessmentModel right = new Emp_AssessmentModel();
            right.ID = (int)dr["ID"];
            right.EmpBasicID = (int)dr["EmpBasicID"];
            right.AssessmentType = dr["AssessmentType"] as string;
            right.AssessmentResult = dr["AssessmentResult"] as string;
            right.EmpName = dr["EmpName"] as string;
            right.EmpNo = dr["EmpNo"] as string;
            right.AssessmentDate = (string.IsNullOrEmpty(dr["AssessmentDate"].ToString()) || dr["AssessmentDate"].ToString() == "1900/1/1 0:00:00") ? null : (DateTime?)dr["AssessmentDate"];
            return right;
        }
    }
}
